package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.CityPlay;
import cn.wolfcode.trip.base.domain.NewsPage;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.CityplayQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IApplicantService;
import cn.wolfcode.trip.base.service.ICityPlayService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("cityPlay")
public class CityPlayController {

    @Autowired
    private ICityPlayService cityPlayService;

    @Autowired
    private IApplicantService applicantService;


    @RequestMapping("list")
    public String query(@ModelAttribute("qo")CityplayQueryObject qo, Model mo, CityPlay cityPlay){
        //查询查出所有的的一起去旅游的信息
        PageInfo<CityPlay> query = cityPlayService.query(qo);
        //查出一条约旅游信息所参加的人数的姓名头像电话
       /* List<User> users=applicantService.selectAllBycityPlayId(cityPlay.getId());*/
        mo.addAttribute("pageInfo",query);
        /*mo.addAttribute("users",users);*/
        return "cityPlay/list";
    }

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(CityPlay cityPlay) {
        JsonResult result = new JsonResult();
        try {
            cityPlayService.saveOrUpdate(cityPlay);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark("亲，操作失败，请重试");
        }
        return result;
    }


}
